produceFunc = function()
    while true do
        local value = io.read()
        print("produce: ", value)
        coroutine.yield(value)        --返回生产的值
    end
end

consumer = function(p)
    while true do
        local status, value = coroutine.resume(p);        --唤醒生产者进行生产
        print("consume: ", value,"status:",status)
    end
end

--消费者驱动的设计，也就是消费者需要产品时找生产者请求，生产者完成生产后提供给消费者
producer = coroutine.create(produceFunc)
consumer(producer)